<!-- uploadify -->
<link rel="stylesheet" href="__PUBLIC__/Style/Common/uploadify/uploadify.css">
<script type="text/javascript" src="__PUBLIC__/Style/Common/uploadify/jquery.uploadify.min.js?{:rand(0,9999)}"></script>
<if condition="$error eq null" >
<form action="" class="form-horizontal" role="form">
  <div class="form-group">
    <label class="col-sm-2 control-label">积币配置项</label>
    <div class="col-sm-4">
      <input class="form-control" readonly="readonly" name="name" datatype="*" value="{$config.cfg.name}">
    </div>
  </div>
  
  <notEmpty name="config['cfg']">
  <foreach name="config['cfg']['fields']" item="vo" key="key">
  <div class="form-group">
    <label class="col-sm-2 control-label">{$vo['name']}</label>
    <div class="col-sm-4">
      <if condition="$vo['type'] eq 'text'" >
      <input class="form-control" name="config[{$key}]" datatype="*" value="{$vo['value']}">
      </if>
    </div>
  </div>
  </foreach>
  </notEmpty>
  
  <div class="form-group">
    <label class="col-sm-2 control-label">是否开启</label>
    <div class="col-sm-4">
      {$config.status}
    </div>
  </div>
  <foreach name="productPayApi.cfg.fields" item="vo" key="k">
  <div class="form-group">
    <label class="col-sm-2 control-label">{$vo.title}
    <if condition="$vo.description">
    <br/><span class="label label-info">{$vo.description}</span>
    </if>
    </label>
    <div class="col-sm-4">
	    <if condition="$vo['type'] eq 'select'">
	    	<select  class="form-control" name="{$vo.name}" datatype="*">
	    		 <foreach name="vo.data" item="vo0" key="k0">
	    		 	<option value="{$k0}" <php>if( ($vo['value']!='' and $vo['value']!=null) and $vo['value']==$k0) { echo "selected"; }</php>>{$vo0}</option>
	    		 </foreach>
	    	</select>
	    <elseif condition="$vo['type'] eq 'file'"/>
	    	<input type="text" id="{$vo.name}" name="{$vo.name}" class="form-control margin-bottom" value="{$vo.value}"/>
			<input type="file" id="{$vo.name}_upload" />
			<script type="text/javascript">
			$(function() {
			    $("#{$vo.name}_upload").uploadify({
			        'multi'			:	false,
			        'fileSizeLimit' : 	'200kb',
			        'buttonText'	:	'选择文件',
			        'fileTypeDesc' 	: 	'PEM Files',
			        'fileTypeExts' 	: 	"<if condition="$vo['filter']">{$vo['filter']}<else/>*.*</if>",
			        'swf'			: 	'__PUBLIC__/Style/Common/uploadify/uploadify.swf',
			        'uploader'		: 	'__MODULE__/Upload/uploadOnePem',
			        'onUploadSuccess'	: function(data, res){
			        	var url = eval("(" + res + ")").extra.saestorPath;
			        	$("#{$vo.name}").val( url );
			        }
			    });
			});
			</script>
	    <else/>
	      	<input class="form-control" name="{$vo.name}" datatype="*" value="{$vo.value}">
	    </if>
    </div>
  </div>
  </foreach>
  <div class="form-group">
    <div class="col-sm-offset-2 col-sm-8">
      <input type="hidden" name="id" value="{$config.id}">
      <input type="hidden" name="tag" value="{$config.tag}">
      <button type="submit" class="btn btn-primary submit" data-loading-txt="提交中，请稍后……" data-ajax-url="__CONTROLLER__/save">保存更改</button>
    </div>
  </div>
</form>
<else/>
{$error}
</if>
